package com.example.maple.ccsclient.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.example.maple.ccsclient.R;

import java.util.List;

/**
 * Created by maple on 2016/6/28.
 */
public class GroupAdapter extends ArrayAdapter<String> {

	Context mContext = null;
	int mResourse;

	public GroupAdapter(Context context, int resource, List<String> objects) {
		super(context, resource, objects);
		mContext = context;
		mResourse = resource;
	}


	//获取每个子项
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {
			convertView = LayoutInflater.from(mContext).inflate(mResourse, null);
			holder = new ViewHolder();

			holder.groupItem = (TextView) convertView.findViewById(R.id.groupItem);
			holder.groupItem.setTextColor(Color.WHITE);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		String info = getItem(position);
		holder.groupItem.setTextColor(Color.BLACK);
		holder.groupItem.setText(info);

		return convertView;
	}

	static class ViewHolder {
		TextView groupItem;
	}
}
